/**
 * address.js-
 */
import request from '../request'
class address {
  constructor() {
    this._defaultHeader = {
      'data-tupe': 'application/json',
    }
    this._request = new request
    this._request.setErrorHandler(this.errorHander)
  }

  /**
   * 统一的异常处理方法
   */
  errorHander(res) {
    console.error(res)
  }


  /**
   * 新增收货地址
   */
  addAddress(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/receiving-information/add', data).then(res => res.data)
  }

  
  /**
   * 编辑收货地址
   */
  editAddress(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/receiving-information/edit', data).then(res => res.data)
  }


  /**
   * 获取10条收货地址
   */
  getAddress(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/receiving-information/get-last-ten', data).then(res => res.data)
  }
}
export default address